package com.itheima.controller;

import com.github.pagehelper.PageInfo;
import com.itheima.pojo.SysLogVO;
import com.itheima.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/log")
public class SysLogController {

    @Autowired
    private SysLogService sysLogService;

    @PostMapping("/getLogList")
    public Map getLogList(@RequestBody SysLogVO sysLogVO){

        PageInfo logList = sysLogService.getLogList(sysLogVO);

        Map<String,Object> result = new HashMap<>();

        Map<String,Object> recordsMap = new HashMap<>();

        recordsMap.put("records",logList.getList());
        recordsMap.put("total",logList.getTotal());
        recordsMap.put("size",10);
        recordsMap.put("current",sysLogVO.getCurrentPage());
        recordsMap.put("orders",null);
        recordsMap.put("optimizeCountSql",true);
        recordsMap.put("isSearchCount",true);

        result.put("code","success");
        result.put("data",recordsMap);
        //返回结果
        return result;
    }
}
